<?php

class AsyncRead
{
    public function __construct()
    {
        //函数风格
        swoole_async_readfile('city.txt', function ($filename, $content) {
            echo $this->setMsg("文件名称:{$filename}");
            echo$this->setMsg("文件内容:{$content}");
        });
    }

    /**
     * 设置消息
     * @Author   Wcj
     * @DateTime 2019/3/14 15:22
     * @param $msg
     * @return string
     */
    public function setMsg($msg)
    {
        return $msg . PHP_EOL;
    }

}

$object = new AsyncRead();

echo $object->setMsg('第二行！！！');